package c.c.c.a.c.c;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import c.c.c.a.i.c;
import c.c.c.a.n;
import com.huawei.agconnect.exception.AGCServerException;

/* compiled from: DuplicateLogDAO */
public class a extends a<c.c.c.a.c.a.a> {
    public final String a = "duplicatelog";

    private void c(SQLiteDatabase sQLiteDatabase, T t) {
        if (sQLiteDatabase != null && t != null) {
            try {
                String str = this.a;
                c.c.c.a.c.a.a aVar = (c.c.c.a.c.a.a) t;
                ContentValues contentValues = new ContentValues();
                contentValues.put("path", aVar.a);
                contentValues.put("insert_time", Long.valueOf(aVar.b));
                sQLiteDatabase.insert(str, null, contentValues);
            } catch (Exception unused) {
                Context context = n.a;
                c cVar = n.d;
            }
        }
    }

    public void a(SQLiteDatabase sQLiteDatabase, c.c.c.a.c.a.a aVar) {
        String str = "_id";
        if (aVar != null && !b(sQLiteDatabase, aVar.a)) {
            c(sQLiteDatabase, aVar);
            try {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("delete from ");
                stringBuilder.append(this.a);
                stringBuilder.append(" where ");
                stringBuilder.append(str);
                stringBuilder.append(" in (select ");
                stringBuilder.append(str);
                stringBuilder.append(" from ");
                stringBuilder.append(this.a);
                stringBuilder.append(" order by ");
                stringBuilder.append("insert_time");
                stringBuilder.append(" desc limit 1000 offset ");
                stringBuilder.append(AGCServerException.UNKNOW_EXCEPTION);
                stringBuilder.append(")");
                sQLiteDatabase.execSQL(stringBuilder.toString());
            } catch (Exception unused) {
                Context context = n.a;
                c cVar = n.d;
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:14:0x002b  */
    public boolean b(android.database.sqlite.SQLiteDatabase r11, java.lang.String r12) {
        /*
        r10 = this;
        r0 = 0;
        if (r11 == 0) goto L_0x002c;
    L_0x0003:
        r1 = android.text.TextUtils.isEmpty(r12);
        if (r1 == 0) goto L_0x000a;
    L_0x0009:
        goto L_0x002c;
    L_0x000a:
        r1 = 1;
        r3 = r10.a;	 Catch:{ Exception -> 0x0024 }
        r4 = 0;
        r5 = "path=?";
        r6 = new java.lang.String[r1];	 Catch:{ Exception -> 0x0024 }
        r6[r0] = r12;	 Catch:{ Exception -> 0x0024 }
        r7 = 0;
        r8 = 0;
        r9 = 0;
        r2 = r11;
        r11 = r2.query(r3, r4, r5, r6, r7, r8, r9);	 Catch:{ Exception -> 0x0024 }
        r12 = r11.getCount();	 Catch:{ Exception -> 0x0024 }
        r11.close();	 Catch:{ Exception -> 0x0025 }
        goto L_0x0029;
    L_0x0024:
        r12 = 0;
    L_0x0025:
        r11 = c.c.c.a.n.a;
        r11 = c.c.c.a.n.d;
    L_0x0029:
        if (r12 <= 0) goto L_0x002c;
    L_0x002b:
        r0 = 1;
    L_0x002c:
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.c.a.c.c.a.b(android.database.sqlite.SQLiteDatabase, java.lang.String):boolean");
    }
}
